<?php

use Illuminate\Database\Seeder;
use App\Models\User;

class FollowersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //
        $users= User::all();
        $user =$users->first();
        $user_id =$user->id;
        //获取去除id 为1 的所有用户id 数组
        $followers=$users->slice(1);
        $follower_ids = $followers->pluck('id')->toArray();

        $user->follow($follower_ids);

        foreach ($followers as $follower) {
          $follower->follow($user_id);
        }

    }
}
